#include <cd.h>
#include <wd.h>
#include <cdiup.h>

#include <cdnative.h>
#include <cdclipbd.h>
#include <cdprint.h>
#include <cdpicture.h>
#include <cdirgb.h>
#include <cdimage.h>
#include <cddbuf.h>
#include <cdpdf.h>
#include <cdps.h>
#include <cdmf.h>
#include <cdcgm.h>
#include <cddxf.h>
#include <cddgn.h>
#include <cdemf.h>
#include <cdwmf.h>
#include <cddebug.h>

#include "cdgl.h"


#ifdef WIN32
#define EXPORT(T) extern "C" __declspec(dllexport) T
#elif defined LIN26
#define EXPORT(T) extern "C"  T
#endif

//canvas functions/////////////////////////////////////////////////////////////
//initialization
EXPORT(cdCanvas*)   CreateCanvas(cdContext* context,void* data) {return cdCreateCanvas(context,data);}
EXPORT(void)        KillCanvas(cdCanvas* canvas) {cdKillCanvas(canvas);}
EXPORT(int)         CanvasActivate(cdCanvas *canvas) {return cdCanvasActivate(canvas);}
EXPORT(void)        CanvasDeactivate(cdCanvas* canvas) {cdCanvasDeactivate(canvas);}
//EXPORT(int)         UseContextPlus(int use) {return cdUseContextPlus(use);} todo: enable this, missing lib file?
//EXPORT(void)        InitContextPlus(void) {cdInitContextPlus();} todo: enable this, missing lib file?
EXPORT(cdContext*)  CanvasGetContext(cdCanvas *canvas) {return cdCanvasGetContext(canvas);}
EXPORT(int)         ContextCaps(cdContext* ctx) {return cdContextCaps(ctx);}
EXPORT(int)         CanvasSimulate(cdCanvas* canvas, int mode) {return cdCanvasSimulate(canvas,mode);}
//control
EXPORT(void)        CanvasClear(cdCanvas* canvas) {cdCanvasClear(canvas);}
EXPORT(void)        CanvasFlush(cdCanvas* canvas) {cdCanvasFlush(canvas);}
EXPORT(cdState*)    CanvasSaveState(cdCanvas* canvas) {return cdCanvasSaveState(canvas);}
EXPORT(void)        CanvasRestoreState(cdCanvas* canvas, cdState* state) {cdCanvasRestoreState(canvas,state);}
EXPORT(void)        ReleaseState(cdState* state) {cdReleaseState(state);}
EXPORT(void)        CanvasSetAttribute(cdCanvas* canvas, const char* name, char* data) {cdCanvasSetAttribute(canvas,name,data);}
EXPORT(char*)       CanvasGetAttribute(cdCanvas* canvas, const char* name) {return cdCanvasGetAttribute(canvas,name);}
//general attributes
EXPORT(int)         CanvasForeground(cdCanvas* canvas, long int color) {return cdCanvasForeground(canvas,color);}
EXPORT(void)        CanvasSetForeground(cdCanvas* canvas, long int color) {cdCanvasSetForeground(canvas,color);}
EXPORT(int)         CanvasBackground(cdCanvas* canvas, long int color) {return cdCanvasBackground(canvas,color);}
EXPORT(void)        CanvasSetBackground(cdCanvas* canvas, long int color) {cdCanvasSetBackground(canvas,color);}
EXPORT(int)         CanvasWriteMode(cdCanvas* canvas, int mode) {return cdCanvasWriteMode(canvas,mode);}
//coordinate systems
EXPORT(void) CanvasGetSize(cdCanvas* canvas, int *width, int *height, double *width_mm, double *height_mm) {cdCanvasGetSize(canvas,width,height,width_mm,height_mm);}
EXPORT(int) CanvasUpdateYAxis(cdCanvas* canvas, int *y) {return cdCanvasUpdateYAxis(canvas,y);}
EXPORT(double) FCanvasUpdateYAxis(cdCanvas* canvas, double *y) {return cdfCanvasUpdateYAxis(canvas,y);}
EXPORT(int) CanvasInvertYAxis(cdCanvas* canvas, int y) {return cdCanvasInvertYAxis(canvas,y);}
EXPORT(double) FCanvasInvertYAxis(cdCanvas* canvas, double y) {return cdfCanvasInvertYAxis(canvas,y);}
EXPORT(void) CanvasMM2Pixel(cdCanvas* canvas, double mm_dx, double mm_dy, int *dx, int *dy) {cdCanvasMM2Pixel(canvas,mm_dx,mm_dy,dx,dy);}
EXPORT(void) FCanvasMM2Pixel(cdCanvas* canvas, double mm_dx, double mm_dy, double *dx, double *dy) {cdfCanvasMM2Pixel(canvas,mm_dx,mm_dy,dx,dy);}
EXPORT(void) CanvasPixel2MM(cdCanvas* canvas, int dx, int dy, double *mm_dx, double *mm_dy) {cdCanvasPixel2MM(canvas,dx,dy,mm_dx,mm_dy);}
EXPORT(void) FCanvasPixel2MM(cdCanvas* canvas, double dx, double dy, double *mm_dx, double *mm_dy) {cdfCanvasPixel2MM(canvas,dx,dy,mm_dx,mm_dy);}
EXPORT(void) CanvasOrigin(cdCanvas* canvas, int x, int y) {cdCanvasOrigin(canvas,x,y);}
EXPORT(void) FCanvasOrigin(cdCanvas* canvas, double x, double y) {cdfCanvasOrigin(canvas,x,y);}
EXPORT(void) CanvasGetOrigin(cdCanvas* canvas, int *x, int *y) {cdCanvasGetOrigin(canvas,x,y);}
EXPORT(void) FCanvasGetOrigin(cdCanvas* canvas, double *x, double *y) {cdfCanvasGetOrigin(canvas,x,y);}
EXPORT(void) CanvasTransform(cdCanvas* canvas, const double* matrix) {cdCanvasTransform(canvas,matrix);}
EXPORT(double*) CanvasGetTransform(cdCanvas* canvas) {return cdCanvasGetTransform(canvas);}
EXPORT(void) CanvasTransformMultiply(cdCanvas* canvas, const double* matrix) {cdCanvasTransformMultiply(canvas,matrix);}
EXPORT(void) CanvasTransformTranslate(cdCanvas* canvas, double dx, double dy) {cdCanvasTransformTranslate(canvas,dx,dy);}
EXPORT(void) CanvasTransformScale(cdCanvas* canvas, double sx, double sy) {cdCanvasTransformScale(canvas,sx,sy);}
EXPORT(void) CanvasTransformRotate(cdCanvas* canvas, double angle) {cdCanvasTransformRotate(canvas,angle);}
EXPORT(void) CanvasTransformPoint(cdCanvas* canvas, int x, int y, int *tx, int *ty) {cdCanvasTransformPoint(canvas,x,y,tx,ty);}
EXPORT(void) FCanvasTransformPoint(cdCanvas* canvas, double x, double y, double *tx, double *ty) {cdfCanvasTransformPoint(canvas,x,y,tx,ty);}
//world coordinates
EXPORT(void) WCanvasWindow(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax) {wdCanvasWindow(canvas,xmin,xmax,ymin,ymax);}
EXPORT(void) WCanvasGetWindow(cdCanvas* canvas, double *xmin, double *xmax, double *ymin, double *ymax) {wdCanvasGetWindow(canvas,xmin,xmax,ymin,ymax);}
EXPORT(void) WCanvasViewport(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax) {wdCanvasViewport(canvas,xmin,xmax,ymin,ymax);}
EXPORT(void) WCanvasGetViewport(cdCanvas* canvas, int *xmin, int *xmax, int *ymin, int *ymax) {wdCanvasGetViewport(canvas,xmin,xmax,ymin,ymax);}
EXPORT(void) WCanvasWorld2Canvas(cdCanvas* canvas, double xw, double yw, int *xv, int *yv) {wdCanvasWorld2Canvas(canvas,xw,yw,xv,yv);}
EXPORT(void) WCanvasCanvas2World(cdCanvas* canvas, int xv, int yv, double *xw, double *yw) {wdCanvasCanvas2World(canvas,xv,yv,xw,yw);}
EXPORT(void) WCanvasHardcopy(cdCanvas *canvas, cdContext* ctx, void *data, void(*draw_func)(cdCanvas *canvas_copy)) {wdCanvasHardcopy(canvas,ctx,data,draw_func);}
//clipping
EXPORT(int) CanvasClip(cdCanvas* canvas, int mode) {return cdCanvasClip(canvas,mode);}
EXPORT(void) CanvasClipArea(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax) {cdCanvasClipArea(canvas,xmin,xmax,ymin,ymax);}
EXPORT(void) FCanvasClipArea(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax) {cdfCanvasClipArea(canvas,xmin,xmax,ymin,ymax);}
EXPORT(void) WCanvasClipArea(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax) {wdCanvasClipArea(canvas,xmin,xmax,ymin,ymax);}
EXPORT(int) CanvasGetClipArea(cdCanvas* canvas, int *xmin, int *xmax, int *ymin, int *ymax) {return cdCanvasGetClipArea(canvas,xmin,xmax,ymin,ymax);}
EXPORT(int) FCanvasGetClipArea(cdCanvas* canvas, double *xmin, double *xmax, double *ymin, double *ymax) {return cdfCanvasGetClipArea(canvas,xmin,xmax,ymin,ymax);}
EXPORT(int) WCanvasGetClipArea(cdCanvas* canvas, double *xmin, double *xmax, double *ymin, double *ymax) {return wdCanvasGetClipArea(canvas,xmin,xmax,ymin,ymax);}
EXPORT(int) CanvasRegionCombineMode(cdCanvas* canvas, int mode) {return cdCanvasRegionCombineMode(canvas,mode);}
EXPORT(int) CanvasIsPointInRegion(cdCanvas* canvas, int x, int y) {return cdCanvasIsPointInRegion(canvas,x,y);}
EXPORT(void) CanvasOffsetRegion(cdCanvas* canvas, int dx, int dy) {cdCanvasOffsetRegion(canvas,dx,dy);}
EXPORT(void) WCanvasOffsetRegion(cdCanvas* canvas, double dx, double dy) {wdCanvasOffsetRegion(canvas,dx,dy);}
EXPORT(void) CanvasGetRegionBox(cdCanvas* canvas, int *xmin, int *xmax, int *ymin, int *ymax) {cdCanvasGetRegionBox(canvas,xmin,xmax,ymin,ymax);}
EXPORT(void) WCanvasGetRegionBox(cdCanvas* canvas, double *xmin, double *xmax, double *ymin, double *ymax) {wdCanvasGetRegionBox(canvas,xmin,xmax,ymin,ymax);}




//marks and pixels///////////////////////////////////////////////
EXPORT(void)        CanvasPixel(cdCanvas* canvas, int x, int y, long int color) {cdCanvasPixel(canvas,x,y,color);}
EXPORT(void)        WCanvasPixel(cdCanvas* canvas, double x, double y, long int color) {wdCanvasPixel(canvas,x,y,color);}
EXPORT(void)        CanvasMark(cdCanvas* canvas, int x, int y) {cdCanvasMark(canvas,x,y);}
EXPORT(void)        WCanvasMark(cdCanvas* canvas, double x, double y) {wdCanvasMark(canvas,x,y);}
//attributes
EXPORT(int)         CanvasMarkType(cdCanvas* canvas, int type) {return cdCanvasMarkType(canvas,type);}
EXPORT(int)         CanvasMarkSize(cdCanvas* canvas, int size) {return cdCanvasMarkSize(canvas,size);}
EXPORT(double)      WCanvasMarkSize(cdCanvas* canvas, double size) {return wdCanvasMarkSize(canvas,size);}

//line primitives////////////////////////////////////////////////
EXPORT(void)        CanvasLine(cdCanvas* canvas,int x1,int y1,int x2,int y2) {cdCanvasLine(canvas,x1,y1,x2,y2);}
EXPORT(void)        FCanvasLine(cdCanvas* canvas,double x1,double y1,double x2,double y2) {cdfCanvasLine(canvas,x1,y1,x2,y2);}
EXPORT(void)        WCanvasLine(cdCanvas* canvas,double x1,double y1,double x2,double y2) {wdCanvasLine(canvas,x1,y1,x2,y2);}
EXPORT(void)        CanvasBegin(cdCanvas* canvas,int mode) {cdCanvasBegin(canvas,mode);}
EXPORT(void)        CanvasVertex(cdCanvas* canvas,int x,int y) {cdCanvasVertex(canvas,x,y);}
EXPORT(void)        FCanvasVertex(cdCanvas* canvas,double x,double y) {cdfCanvasVertex(canvas,x,y);}
EXPORT(void)        WCanvasVertex(cdCanvas* canvas,double x,double y) {wdCanvasVertex(canvas,x,y);}
EXPORT(void)        CanvasEnd(cdCanvas* canvas) {cdCanvasEnd(canvas);}
EXPORT(void)        CanvasRect(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax) {cdCanvasRect(canvas,xmin,xmax,ymin,ymax);}
EXPORT(void)        FCanvasRect(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax) {cdfCanvasRect(canvas,xmin,xmax,ymin,ymax);}
EXPORT(void)        WCanvasRect(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax) {wdCanvasRect(canvas,xmin,xmax,ymin,ymax);}
EXPORT(void)        CanvasArc(cdCanvas* canvas, int xc, int yc, int w, int h, double angle1, double angle2) {cdCanvasArc(canvas,xc,yc,w,h,angle1,angle2);}
EXPORT(void)        FCanvasArc(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2) {cdfCanvasArc(canvas,xc,yc,w,h,angle1,angle2);}
EXPORT(void)        WCanvasArc(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2) {wdCanvasArc(canvas,xc,yc,w,h,angle1,angle2);}
//attributes
EXPORT(int)         CanvasLineStyle(cdCanvas* canvas, int style) {return cdCanvasLineStyle(canvas,style);}
EXPORT(void)        CanvasLineStyleDashes(cdCanvas* canvas, const int* dashes, int count) {cdCanvasLineStyleDashes(canvas,dashes,count);}
EXPORT(int)         CanvasLineWidth(cdCanvas* canvas, int width) {return cdCanvasLineWidth(canvas,width);}
EXPORT(double)      WCanvasLineWidth(cdCanvas* canvas,double width_mm) {return wdCanvasLineWidth(canvas,width_mm);}
EXPORT(int)         CanvasLineJoin(cdCanvas* canvas, int join) {return cdCanvasLineJoin(canvas,join);}
EXPORT(int)         CanvasLineCap(cdCanvas* canvas, int cap) {return cdCanvasLineCap(canvas,cap);}





//filled primitives/////////////////////////////////////////////////
EXPORT(void)        CanvasBox(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax) {cdCanvasBox(canvas,xmin,xmax,ymin,ymax);}
EXPORT(void)        FCanvasBox(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax) {cdfCanvasBox(canvas,xmin,xmax,ymin,ymax);}
EXPORT(void)        WCanvasBox(cdCanvas* canvas, double xmin, double xmax, double ymin, double ymax) {wdCanvasBox(canvas,xmin,xmax,ymin,ymax);}
EXPORT(void)        CanvasSector(cdCanvas* canvas, int xc, int yc, int w, int h, double angle1, double angle2) {cdCanvasSector(canvas,xc,yc,w,h,angle1,angle2);}
EXPORT(void)        FCanvasSector(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2) {cdfCanvasSector(canvas,xc,yc,w,h,angle1,angle2);}
EXPORT(void)        WCanvasSector(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2) {wdCanvasSector(canvas,xc,yc,w,h,angle1,angle2);}
EXPORT(void)        CanvasChord(cdCanvas* canvas, int xc, int yc, int w, int h, double angle1, double angle2) {cdCanvasChord(canvas,xc,yc,w,h,angle1,angle2);}
EXPORT(void)        FCanvasChord(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2) {cdfCanvasChord(canvas,xc,yc,w,h,angle1,angle2);}
EXPORT(void)        WCanvasChord(cdCanvas* canvas, double xc, double yc, double w, double h, double angle1, double angle2) {wdCanvasChord(canvas,xc,yc,w,h,angle1,angle2);}
//attributes
EXPORT(int)         CanvasBackOpacity(cdCanvas* canvas, int opacity) {return cdCanvasBackOpacity(canvas,opacity);}
EXPORT(int)         CanvasFillMode(cdCanvas* canvas, int mode) {return cdCanvasFillMode(canvas,mode);}
EXPORT(int)         CanvasInteriorStyle(cdCanvas* canvas, int style) {return cdCanvasInteriorStyle(canvas,style);}
EXPORT(int)         CanvasHatch(cdCanvas* canvas, int style) {return cdCanvasHatch(canvas,style);}
EXPORT(void)        CanvasStipple(cdCanvas* canvas, int w, int h, const unsigned char *fgbg) {cdCanvasStipple(canvas,w,h,fgbg);}
EXPORT(void)        WCanvasStipple(cdCanvas* canvas, int w, int h, const unsigned char *fgbg, double w_mm, double h_mm) {wdCanvasStipple(canvas,w,h,fgbg,w_mm,h_mm);}
EXPORT(unsigned char*) CanvasGetStipple(cdCanvas* canvas, int* w, int* h) {return cdCanvasGetStipple(canvas,w,h);}
EXPORT(void)        CanvasPattern(cdCanvas* canvas, int w, int h, const long int *color) {cdCanvasPattern(canvas,w,h,color);}
EXPORT(void)        WCanvasPattern(cdCanvas* canvas, int w, int h, const long int *color, double w_mm, double h_mm) {wdCanvasPattern(canvas,w,h,color,w_mm,h_mm);}
EXPORT(long int*)   CanvasGetPattern(cdCanvas* canvas, int* w, int* h) {return cdCanvasGetPattern(canvas,w,h);}


//text/////////////////////////////////////////////////
EXPORT(void)        CanvasText(cdCanvas* canvas, int x, int y, const char* text) {cdCanvasText(canvas,x,y,text);}
EXPORT(void)        FCanvasText(cdCanvas* canvas, double x, double y, const char* text) {cdfCanvasText(canvas,x,y,text);}
EXPORT(void)        WCanvasText(cdCanvas* canvas, double x, double y, const char* text) {wdCanvasText(canvas,x,y,text);}
//attributes
EXPORT(void)        CanvasFont(cdCanvas* canvas, const char* typeface, int style, int size) {cdCanvasFont(canvas,typeface,style,size);}
EXPORT(void)        WCanvasFont(cdCanvas* canvas, const char* typeface, int style, double size) {wdCanvasFont(canvas,typeface,style,size);}
EXPORT(void)        CanvasGetFont(cdCanvas* canvas, char* typeface, int *style, int *size) {cdCanvasGetFont(canvas,typeface,style,size);}
EXPORT(void)        WCanvasGetFont(cdCanvas* canvas, char* typeface, int *style, double *size) {wdCanvasGetFont(canvas,typeface,style,size);}
EXPORT(char*)       CanvasNativeFont(cdCanvas* canvas, const char* nativefont) {return cdCanvasNativeFont(canvas,nativefont);}
EXPORT(int)         CanvasTextAlignment(cdCanvas* canvas, int alignment) {return cdCanvasTextAlignment(canvas,alignment);}
EXPORT(double)      CanvasTextOrientation(cdCanvas* canvas, double angle) {return cdCanvasTextOrientation(canvas,angle);}
//properties
EXPORT(void)        CanvasGetFontDim(cdCanvas* canvas, int *max_width, int *height, int *ascent, int *descent) {cdCanvasGetFontDim(canvas,max_width,height,ascent,descent);}
EXPORT(void)        WCanvasGetFontDim(cdCanvas* canvas, double *max_width, double *height, double *ascent, double *descent) {wdCanvasGetFontDim(canvas,max_width,height,ascent,descent);}
EXPORT(void)        CanvasGetTextSize(cdCanvas* canvas, const char* text, int *width, int *height) {cdCanvasGetTextSize(canvas,text,width,height);}
EXPORT(void)        WCanvasGetTextSize(cdCanvas* canvas, const char* text, double *width, double *height) {wdCanvasGetTextSize(canvas,text,width,height);}
EXPORT(void)        CanvasGetTextBounds(cdCanvas* canvas, int x, int y, const char *text, int *rect) {cdCanvasGetTextBounds(canvas,x,y,text,rect);}
EXPORT(void)        WCanvasGetTextBounds(cdCanvas* canvas, double x, double y, const char* text, double *rect) {wdCanvasGetTextBounds(canvas,x,y,text,rect);}
EXPORT(void)        CanvasGetTextBox(cdCanvas* canvas, int x, int y, const char* text, int *xmin, int *xmax, int *ymin, int *ymax) {cdCanvasGetTextBox(canvas,x,y,text,xmin,xmax,ymin,ymax);}
EXPORT(void)        WCanvasGetTextBox(cdCanvas* canvas, double x, double y, const char* text, double *xmin, double *xmax, double *ymin, double *ymax) {wdCanvasGetTextBox(canvas,x,y,text,xmin,xmax,ymin,ymax);}


//vector text//////////////////////////////////////////////////////
EXPORT(void)        CanvasVectorText(cdCanvas* canvas, int x, int y, const char* text) {cdCanvasVectorText(canvas,x,y,text);}
EXPORT(void)        WCanvasVectorText(cdCanvas* canvas, double x, double y, const char* text) {wdCanvasVectorText(canvas,x,y,text);}
EXPORT(void)        CanvasVectorTextDirection(cdCanvas* canvas, int x1, int y1, int x2, int y2) {cdCanvasVectorTextDirection(canvas,x1,y1,x2,y2);}
EXPORT(void)        WCanvasVectorTextDirection(cdCanvas* canvas, double x1, double y1, double x2, double y2) {wdCanvasVectorTextDirection(canvas,x1,y1,x2,y2);}
EXPORT(double*)     CanvasVectorTextTransform(cdCanvas* canvas, const double* matrix) {return cdCanvasVectorTextTransform(canvas,matrix);}
EXPORT(void)        CanvasVectorTextSize(cdCanvas* canvas, int width, int height, const char * text) {cdCanvasVectorTextSize(canvas,width,height,text);}
EXPORT(void)        WCanvasVectorTextSize(cdCanvas* canvas, double width, double height, const char* text) {wdCanvasVectorTextSize(canvas,width,height,text);}
EXPORT(int)         CanvasVectorCharSize(cdCanvas* canvas, int size) {return cdCanvasVectorCharSize(canvas,size);}
EXPORT(double)      WCanvasVectorCharSize(cdCanvas* canvas, double size) {return wdCanvasVectorCharSize(canvas,size);}
EXPORT(void)        CanvasVectorFontSize(cdCanvas* canvas, double size_x, double size_y) {cdCanvasVectorFontSize(canvas,size_x,size_y);}
EXPORT(void)        CanvasGetVectorFontSize(cdCanvas* canvas, double *size_x, double *size_y) {cdCanvasGetVectorFontSize(canvas,size_x,size_y);}
EXPORT(char*)       CanvasVectorFont(cdCanvas* canvas, const char *filename) {return cdCanvasVectorFont(canvas,filename);}
EXPORT(void)        CanvasGetVectorTextSize(cdCanvas* canvas, const char* text, int *width, int *height) {cdCanvasGetVectorTextSize(canvas,text,width,height);}
EXPORT(void)        WCanvasGetVectorTextSize(cdCanvas* canvas, const char* text, double *width, double *height) {wdCanvasGetVectorTextSize(canvas,text,width,height);}
EXPORT(void)        CanvasGetVectorTextBounds(cdCanvas* canvas, char* text, int x, int y, int *rect) {cdCanvasGetVectorTextBounds(canvas,text,x,y,rect);}
EXPORT(void)        WCanvasGetVectorTextBounds(cdCanvas* canvas, char* text, double x, double y, double *rect) {wdCanvasGetVectorTextBounds(canvas,text,x,y,rect);}
EXPORT(void)        CanvasGetVectorTextBox(cdCanvas* canvas, int x, int y, const char* text, int *xmin, int *xmax, int *ymin, int *ymax) {cdCanvasGetVectorTextBox(canvas,x,y,text,xmin,xmax,ymin,ymax);}
EXPORT(void)        WCanvasGetVectorTextBox(cdCanvas* canvas, double x, double y, const char* text, double *xmin, double *xmax, double *ymin, double *ymax) {wdCanvasGetVectorTextBox(canvas,x,y,text,xmin,xmax,ymin,ymax);}

//client images
EXPORT(void) CanvasGetImageRGB(cdCanvas* canvas, unsigned char *r,unsigned char *g, unsigned char *b, int x, int y, int w, int h) {cdCanvasGetImageRGB(canvas,r,g,b,x,y,w,h);}
EXPORT(void) CanvasPutImageRectRGB(cdCanvas* canvas, int iw, int ih, const unsigned char *r, const unsigned char *g,const unsigned char *b,int x, int y, int w, int h,int xmin, int xmax, int ymin, int ymax) {cdCanvasPutImageRectRGB(canvas,iw,ih,r,g,b,x,y,w,h,xmin,xmax,ymin,ymax);}
EXPORT(void) WCanvasPutImageRectRGB(cdCanvas* canvas, int iw, int ih,const unsigned char *r,const unsigned char *g,const unsigned char *b,double x, double y, double w, double h,int xmin, int xmax, int ymin, int ymax) {wdCanvasPutImageRectRGB(canvas,iw,ih,r,g,b,x,y,w,h,xmin,xmax,ymin,ymax);}
EXPORT(void) CanvasPutImageRectRGBA(cdCanvas* canvas, int iw, int ih,const unsigned char *r,const unsigned char *g,const unsigned char *b,const unsigned char *a,int x, int y, int w, int h,int xmin, int xmax, int ymin, int ymax) {cdCanvasPutImageRectRGBA(canvas,iw,ih,r,g,b,a,x,y,w,h,xmin,xmax,ymin,ymax);}
EXPORT(void) WCanvasPutImageRectRGBA(cdCanvas* canvas, int iw, int ih,const unsigned char *r,const unsigned char *g,const unsigned char *b,const unsigned char *a,double x, double y, double w, double h,int xmin, int xmax, int ymin, int ymax) {wdCanvasPutImageRectRGBA(canvas,iw,ih,r,g,b,a,x,y,w,h,xmin,xmax,ymin,ymax);}
EXPORT(void) CanvasPutImageRectMap(cdCanvas* canvas, int iw, int ih,const unsigned char *index,const long int *colors,int x, int y, int w, int h,int xmin, int xmax, int ymin, int ymax) {cdCanvasPutImageRectMap(canvas,iw,ih,index,colors,x,y,w,h,xmin,xmax,ymin,ymax);}
EXPORT(void) WCanvasPutImageRectMap(cdCanvas* canvas, int iw, int ih,const unsigned char *index,const long int *colors,double x, double y, double w, double h,int xmin, int xmax, int ymin, int ymax) {wdCanvasPutImageRectMap(canvas,iw,ih,index,colors,x,y,w,h,xmin,xmax,ymin,ymax);}
EXPORT(void) RGB2Map(int iw, int ih,const unsigned char *r,const unsigned char *g,const unsigned char *b,unsigned char *index,int pal_size, long *color) {cdRGB2Map(iw,ih,r,g,b,index,pal_size,color);}
EXPORT(cdBitmap*) CreateBitmap(int w, int h, int type) {return cdCreateBitmap(w,h,type);}
EXPORT(void) KillBitmap(cdBitmap* image) {cdKillBitmap(image);}
EXPORT(unsigned char*) BitmapGetData(cdBitmap* image, int dataptr) {return cdBitmapGetData(image,dataptr);}
EXPORT(void) BitmapSetRect(cdBitmap* image, int xmin, int xmax, int ymin, int ymax) {cdBitmapSetRect(image,xmin,xmax,ymin,ymax);}
EXPORT(void) CanvasPutBitmap(cdCanvas* canvas, cdBitmap* image, int x, int y, int w, int h) {cdCanvasPutBitmap(canvas,image,x,y,w,h);}
EXPORT(void) WCanvasPutBitmap(cdCanvas* canvas, cdBitmap* image, double x, double y, double w, double h) {wdCanvasPutBitmap(canvas,image,x,y,w,h);}
EXPORT(void) CanvasGetBitmap(cdCanvas* canvas, cdBitmap* image, int x, int y) {cdCanvasGetBitmap(canvas,image,x,y);}
EXPORT(void) BitmapRGB2Map(cdBitmap* image_rgb, cdBitmap* image_map) {cdBitmapRGB2Map(image_rgb,image_map);}

//server images
EXPORT(cdImage*) CanvasCreateImage(cdCanvas* canvas, int w, int h) {return cdCanvasCreateImage(canvas,w,h);}
EXPORT(void) KillImage(cdImage* image) {cdKillImage(image);}
EXPORT(void) CanvasGetImage(cdCanvas* canvas, cdImage* image, int x, int y) {cdCanvasGetImage(canvas,image,x,y);}
EXPORT(void) CanvasPutImageRect(cdCanvas* canvas, cdImage* image, int x, int y, int xmin, int xmax, int ymin, int ymax) {cdCanvasPutImageRect(canvas,image,x,y,xmin,xmax,ymin,ymax);}
EXPORT(void) WCanvasPutImageRect(cdCanvas* canvas, cdImage* image, double x, double y, int xmin, int xmax, int ymin, int ymax) {wdCanvasPutImageRect(canvas,image,x,y,xmin,xmax,ymin,ymax);}
EXPORT(void) CanvasScrollArea(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, int dx, int dy) {cdCanvasScrollArea(canvas,xmin,xmax,ymin,ymax,dx,dy);}

//system
/*EXPORT(char*) Version(void) {return cdVersion();}
EXPORT(char*) VersionDate(void) {return cdVersionDate();}
EXPORT(int) VersionNumber(void) {return cdVersionNumber();}*/

//metafiles
EXPORT(int) CanvasPlay(cdCanvas* canvas, cdContext* ctx, int xmin, int xmax, int ymin, int ymax, void *data) {return cdCanvasPlay(canvas,ctx,xmin,xmax,ymin,ymax,data);}
//EXPORT(int) cdContextRegisterCallback(cdContext *ctx, int cb, int(*func)(cdCanvas* canvas, ...)) todo: can we get this to function in c# (varargs...)

//color coding
EXPORT(int) EncodeColor(unsigned char red, unsigned char green, unsigned char blue) {return cdEncodeColor(red,green,blue);}
EXPORT(void) DecodeColor(long int color, unsigned char *red, unsigned char *green, unsigned char *blue) {cdDecodeColor(color,red,green,blue);}
EXPORT(long int) EncodeAlpha(long int color, unsigned char alpha) {return cdEncodeAlpha(color,alpha);}
EXPORT(unsigned char) DecodeAlpha(long int color) {return cdDecodeAlpha(color);}
EXPORT(unsigned char) Alpha(long int color) {return cdAlpha(color);}
EXPORT(unsigned char) Red(long int color) {return cdRed(color);}
EXPORT(unsigned char) Green(long int color) {return cdGreen(color);}
EXPORT(unsigned char) Blue(long int color) {return cdBlue(color);}
EXPORT(int) CanvasGetColorPlanes(cdCanvas* canvas) {return cdCanvasGetColorPlanes(canvas);}
EXPORT(void) CanvasPalette(cdCanvas* canvas, int n, const long int *color, int mode) {cdCanvasPalette(canvas,n,color,mode);}

//drivers/////////////////////////////////////////////////////////////////////
EXPORT(cdContext*)  ContextNativeWindow() {return cdContextNativeWindow();}
EXPORT(cdContext*)  ContextIup() {return cdContextIup();}
EXPORT(cdContext*)  ContextClipboard() {return cdContextClipboard();}
EXPORT(cdContext*)  ContextPrinter() {return cdContextPrinter();}
EXPORT(cdContext*)  ContextPicture() {return cdContextPicture();}
EXPORT(cdContext*)  ContextImageRGB() {return cdContextImageRGB();} //client rgb
EXPORT(cdContext*)  ContextDBufferRGB() {return cdContextDBufferRGB();} //client double buffer
EXPORT(cdContext*)  ContextImage() {return cdContextImage();} //server image
EXPORT(cdContext*)  ContextDBuffer() {return cdContextDBuffer();} //server double buffer
EXPORT(cdContext*)  ContextPDF() {return cdContextPDF();} //portable document format
EXPORT(cdContext*)  ContextPS() {return cdContextPS();} //postscript
EXPORT(cdContext*)  ContextMetafile() {return cdContextMetafile();} //cd metafile
EXPORT(cdContext*)  ContextCGM() {return cdContextCGM();}
EXPORT(cdContext*)  ContextDGN() {return cdContextDGN();}
EXPORT(cdContext*)  ContextDXF() {return cdContextDXF();}
EXPORT(cdContext*)  ContextWMF() {return cdContextWMF();}
EXPORT(cdContext*)  ContextEMF() {return cdContextEMF();}
EXPORT(cdContext*)  ContextDebug() {return cdContextDebug();}

//EXPORT(cdContext*)  ContextGL() {return cdContextGL();}
